package edu.indiana.d2i.ontology.exec;

import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;

import edu.indiana.d2i.ontology.AbstractSQLExec;
import edu.indiana.d2i.ontology.util.AccessDBUtil;

public class Organ extends AbstractSQLExec {
	private final String prefix = "organ_";

	public Organ(AccessDBUtil dbCon, OntModel model, int id, String subjectURI) {
		super(dbCon, model, id, subjectURI);
		resourceURI = nameSpace + prefix + id; // set the URI for the resource
	}

	@Override
	protected void addObjectProperties(String subjectURI) {
		Resource resource = model.getResource(resourceURI);
		
		// add parent object properties
		if (subjectURI != null) {
			Property pHasParentRelation = model.createProperty(nameSpace + "belongs_to");
			model.add(resource, pHasParentRelation, model.createResource(subjectURI));
		}
	}

	@Override
	public void setData2JenaModel() {
		// query against the database
		sqlStatement = "select * from F_ORGAN where ID=" + id;
		super.setData2JenaModel();
	}
}
